home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d968.lha / JustLook / Examples / ExampleSources / WBExecute.jl.c < prev    next >
C/C++ Source or Header  |  1993-12-04  |  2KB  |  77 lines

  1. /* WBExecute.jl  By Kamran Karimi.
  2.  
  3.    Should be linked with JustLook (© Kamran Karimi) routines.
  4. */
  5.  
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <intuition/intuition.h>
  9. #include <clib/exec_protos.h>
  10. #include <clib/dos_protos.h>
  11. #include <clib/intuition_protos.h>
  12.  
  13. #include "JustLook.h"
  14.  
  15. struct RawInfo BackSp = {0x41,0}; 
  16.  
  17. struct RawInfo Command[] = { /* Avail FLUSH */
  18.  {0x20,LSHIFT}, {0x34,0}, {0x20,0}, {0x17,0}, {0x28,0}, {0x40,0}, 
  19.  {0x23,LSHIFT}, {0x28,LSHIFT}, {0x16,RSHIFT}, {0x21,RSHIFT}, {0x25,RSHIFT}
  20. };
  21.  
  22. struct IntuitionBase *IntuitionBase;
  23.  
  24. #define Write_err printf("err = %08lx\n",err)
  25.  
  26. main()
  27. {
  28.  struct Window *win1,*win2,*win3;
  29.  struct Gadget *StrGad;
  30.  struct StringInfo *StrInfo;
  31.  ErrorCode err;
  32.  struct ScrMap SM;
  33.  int count;
  34.  
  35.  IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
  36.  if(IntuitionBase == 0) exit(100);
  37.  
  38.  win1 = FindWindow("Workbench",NULL);
  39.  if(win1 > WIN_REPEATED) 
  40.  {
  41.   err = IEDisable(MOUSE|KBD); Write_err; /* no fiddling! */
  42.   Delay(25);
  43.   ActivateWindow(win1); /* this is very important! */
  44.   printf("Mouse and keyboard disabled!\n"); 
  45.   InitSM(&SM,win1->WScreen);
  46.   Delay(50);
  47.   err = ChooseMenu(&SM,win1,0,1,-1); Write_err;
  48.   Delay(50);
  49.   win2 = FindWindow("Execute a File",NULL);
  50.   if(win2 > WIN_REPEATED)
  51.   {
  52.    StrGad = FindGad(win2,NULL,1);
  53.    StrInfo = (struct StringInfo *)StrGad->SpecialInfo;
  54.    if(StrInfo->BufferPos > 0)
  55.     for(count = StrInfo->BufferPos; count > 0;count--)
  56.      RawType(&BackSp,1,5); /* delete prev text */
  57.    Delay(25);
  58.    err = RawType(Command,11,20); Write_err;/* type 'Avail FLUSH' */
  59.    err = ClickGad(&SM,win2,NULL,2,1); Write_err; /* click Ok */
  60.    Delay(200); /* wait 4 seconds! */
  61.    win3 = FindWindow("Output Window",NULL);
  62.    if(win3 > WIN_REPEATED)
  63.    {
  64.     Delay(100);
  65.     WinAct(&SM,win3,CLOSEWIN);
  66.    }
  67.    else printf("Trouble finding Output Window!\n");
  68.   }
  69.   else printf("Trouble finding Window for File Execution!\n");
  70.   printf("Program ended!\n");
  71.   err = IEEnable(MOUSE|KBD); Write_err;
  72.  }
  73.  else printf("Trouble finding Workbench window!\n");
  74.  CloseLibrary((struct Library *)IntuitionBase);
  75.  exit(0);
  76. }
  77.